package cn.stack.springframework.test;

import cn.bugstack.springframework.context.support.ClassPathXmlApplicationContext;
import cn.stack.springframework.test.bean.UserService2;
import org.junit.Test;

public class ApiTest08 {
    @Test
    public void test_xml(){
        //初始化BeanFactory
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring.xml");
        applicationContext.registerShutdownHook();
        //获取Bean对象调用方法
        UserService2 userService = applicationContext.getBean("userService", UserService2.class);
        String result = userService.queryUserInfo();
        System.out.println("测试结果: "+result);
        System.out.println("ApplicationContextAware: "+userService.getApplicationContext());
        System.out.println("BeanFactoryAware: "+userService.getBeanFactory());

    }
}
